home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / PROGRAMMING / DESKLIBC / SOURCES.ZIP / DeskLib / !DLSources / Libraries / Menu2 / c / Attach next >
Text File  |  1995-06-22  |  2KB  |  103 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    Menu2.Attach.c
  12.     Author:  Copyright © 1995 Julian Smith
  13.     Version: 1.00 (22 Jun 1995)
  14.     Purpose: Attaching menus to icons/windows.
  15. */
  16.  
  17.  
  18. #include "DeskLib:Event.h"
  19. #include "DeskLib:Menu2.h"
  20.  
  21.  
  22.  
  23. static BOOL    Menu2__OpenFromClick( 
  24.     event_pollblock    *event, 
  25.     menu2_handle    menu, 
  26.     int        button
  27.     )
  28. {
  29. if ( event->data.mouse.button.value != button)    return FALSE;
  30.  
  31. Menu2_Open( 
  32.     menu, 
  33.     event->data.mouse.pos.x, 
  34.     (event->data.mouse.window < 0) ? -1 : event->data.mouse.pos.y
  35.     );
  36. return TRUE;
  37. }
  38.  
  39.  
  40.  
  41. static BOOL    Menu2__SelectClickHandler( event_pollblock *event, void *reference)
  42. {
  43. return Menu2__OpenFromClick( event, (menu2_handle) reference, button_SELECT);
  44. }
  45.  
  46.  
  47. static BOOL    Menu2__AdjustClickHandler( event_pollblock *event, void *reference)
  48. {
  49. return Menu2__OpenFromClick( event, (menu2_handle) reference, button_ADJUST);
  50. }
  51.  
  52.  
  53.  
  54. static BOOL    Menu2__MenuClickHandler( event_pollblock *event, void *reference)
  55. {
  56. return Menu2__OpenFromClick( event, (menu2_handle) reference, button_MENU);
  57. }
  58.  
  59.  
  60.  
  61. static void    Menu2__AttachOrReleaseMenu(
  62.     window_handle        window, 
  63.     icon_handle        icon, 
  64.     menu2_handle        menu, 
  65.     int            button,
  66.     event_claimorreleasefn    fn
  67.     )
  68. {
  69. if ( button & button_MENU)
  70.     fn( event_CLICK, window, icon, Menu2__MenuClickHandler, (void *) menu );
  71.  
  72. if ( button & button_SELECT)
  73.     fn( event_CLICK, window, icon, Menu2__SelectClickHandler, (void *) menu);
  74.  
  75. if ( button & button_ADJUST)
  76.     fn( event_CLICK, window, icon, Menu2__AdjustClickHandler, (void *) menu);
  77. }
  78.  
  79.  
  80.  
  81.  
  82. void    Menu2_AttachMenu( 
  83.     window_handle    window, 
  84.     icon_handle    icon, 
  85.     menu2_handle    menu, 
  86.     int        button
  87.     )
  88. {
  89. Menu2__AttachOrReleaseMenu( window, icon, menu, button, Event_Claim);
  90. }
  91.  
  92.  
  93.  
  94. void    Menu2_DetachMenu( 
  95.     window_handle    window, 
  96.     icon_handle    icon, 
  97.     menu2_handle    menu, 
  98.     int        button
  99.     )
  100. {
  101. Menu2__AttachOrReleaseMenu( window, icon, menu, button, Event_Release);
  102. }
  103.